<?php


namespace app\common\lib;


use app\common\cachemodel\OrdersLib as OrdersLibCacheModel;
use app\common\cachemodel\ZlVipBoon;
use think\Log;
use think\queue\Job;

class VipTask
{
    /**
     * 星力值更新及权益赠送
     * @param Job $job
     * @param $jobData
     * @throws \Exception
     */
    public function starNumUpdateAndSendBoon(Job $job, $jobData)
    {
        Log::write(date('Y-m-d h:i:s') . ':星力值更新及权益赠送开始：' . json_encode($jobData), 'log');
        if ($job->attempts() > 1)
        {
            $job->delete();
        }
        
        // 更新星力值
        OrdersLibCacheModel::UpdateVipBoon($jobData['orders'], $jobData['gid'], $jobData['isUpdateVipSendBoon']);
        // 激活会员或开通会员赠送权益
        if ($jobData['isSend'])
        {
            (new ZlVipBoon())->vipBoonSend($jobData['orders']['uid']);
        }

        $job->delete();
        Log::write(date('Y-m-d h:i:s') . ':星力值更新及权益赠送结束：' . json_encode($jobData), 'log');
    }
}
